/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package doan;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Windows 7
 */
public class Form2_3 extends javax.swing.JFrame {

    /**
     * Creates new form Form2_3
     */
    public Form2_3()  throws Exception {
        initComponents();
        LoadDB();
    }
public void LoadDB() throws Exception{
		try{
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                String url ="Jdbc:odbc:doan";
		Connection conn = DriverManager.getConnection(url);
		Statement stt=conn.createStatement();
                String sql="INSERT INTO question(name_question,question_a,question_b,question_c,question_d) VALUES('"+ta23_Cauhoi.getText().trim()+"','1114546','HCM','Nam','435435')";
		 stt.executeQuery(sql);

		}catch (SQLException e) {
			System.out.println("Loi thao tac CSDL");
		}
		
	}
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        ta23_Cauhoi = new javax.swing.JTextArea();
        bt23_Them = new javax.swing.JButton();
        bt23_Cancel = new javax.swing.JButton();
        bt23_Logout = new javax.swing.JButton();
        jTextField2 = new javax.swing.JTextField();
        jTextField1 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(800, 600));
        getContentPane().setLayout(null);

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        ta23_Cauhoi.setColumns(20);
        ta23_Cauhoi.setFont(new java.awt.Font("Times New Roman", 2, 18)); // NOI18N
        ta23_Cauhoi.setRows(5);
        jScrollPane1.setViewportView(ta23_Cauhoi);

        jPanel1.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 276, 480, 70));

        bt23_Them.setFont(new java.awt.Font("Times New Roman", 2, 18)); // NOI18N
        bt23_Them.setText("Thêm Câu hỏi");
        bt23_Them.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt23_ThemActionPerformed(evt);
            }
        });
        jPanel1.add(bt23_Them, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 530, -1, -1));

        bt23_Cancel.setFont(new java.awt.Font("Times New Roman", 2, 18)); // NOI18N
        bt23_Cancel.setText("Cancel");
        bt23_Cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt23_CancelActionPerformed(evt);
            }
        });
        jPanel1.add(bt23_Cancel, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 530, -1, -1));

        bt23_Logout.setFont(new java.awt.Font("Times New Roman", 2, 18)); // NOI18N
        bt23_Logout.setText("Log out");
        bt23_Logout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt23_LogoutActionPerformed(evt);
            }
        });
        jPanel1.add(bt23_Logout, new org.netbeans.lib.awtextra.AbsoluteConstraints(640, 530, -1, -1));

        jTextField2.setText("A");
        jPanel1.add(jTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 350, 450, -1));

        jTextField1.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
        jPanel1.add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 490, 90, 30));

        jTextField3.setText("B");
        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });
        jPanel1.add(jTextField3, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 380, 450, -1));

        jTextField4.setText("C");
        jTextField4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField4ActionPerformed(evt);
            }
        });
        jPanel1.add(jTextField4, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 420, 450, -1));

        jTextField5.setText("D");
        jPanel1.add(jTextField5, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 460, 450, -1));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/doan/mslide2_3.jpg"))); // NOI18N
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 10, 800, 600));

        getContentPane().add(jPanel1);
        jPanel1.setBounds(0, -20, 800, 600);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bt23_CancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt23_CancelActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
        Form2 t=new Form2();
        t.setVisible(true);
    }//GEN-LAST:event_bt23_CancelActionPerformed

    private void bt23_LogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt23_LogoutActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
        Form1 t3 = null;
        try {
            t3 = new Form1();
        } catch (Exception ex) {
            Logger.getLogger(Form2_3.class.getName()).log(Level.SEVERE, null, ex);
        }
        t3 .setVisible(true);
    }//GEN-LAST:event_bt23_LogoutActionPerformed

    private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField4ActionPerformed

    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField3ActionPerformed

    private void bt23_ThemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt23_ThemActionPerformed
        
    }//GEN-LAST:event_bt23_ThemActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Form2_3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Form2_3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Form2_3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Form2_3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new Form2_3().setVisible(true);
                } catch (Exception ex) {
                    Logger.getLogger(Form2_3.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bt23_Cancel;
    private javax.swing.JButton bt23_Logout;
    private javax.swing.JButton bt23_Them;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextArea ta23_Cauhoi;
    // End of variables declaration//GEN-END:variables
}
